<SecretListHeader
  @isCertTab={{eq tab "certs"}}
  @model={{backendModel}}
  @baseKey={{baseKey}}
  @backendCrumb={{backendCrumb}}
  @filter={{filter}}
/>

{{#with (options-for-backend backendType tab) as |options|}}
  {{#if (or model.meta.total (not isConfigurableTab))}}
    <Toolbar>
      {{#if model.meta.total}}
        <ToolbarFilters>
          {{navigate-input
            enterpriseProduct="vault"
            filterFocusDidChange=(action "setFilterFocus")
            filterDidChange=(action "setFilter")
            filter=filter
            filterMatchesKey=filterMatchesKey
            firstPartialMatch=firstPartialMatch
            baseKey=(get baseKey "id")
            shouldNavigateTree=options.navigateTree
            placeholder=options.searchPlaceholder
            mode=(if (eq tab 'certs') 'secrets-cert' 'secrets')
            data-test-nav-input=true
          }}
          {{#if filterFocused}}
            {{#if filterMatchesKey}}
              {{#unless filterIsFolder}}
                <p class="input-hint">
                  <kbd>Enter</kbd> to view {{filter}}
                </p>
              {{/unless}}
            {{/if}}
            {{#if firstPartialMatch}}
              <p class="input-hint">
                <kbd>Tab</kbd> to autocomplete
              </p>
            {{/if}}
          {{/if}}
        </ToolbarFilters>
      {{/if}}

      <ToolbarActions>
        {{#unless options.hideCreate}}
          <ToolbarSecretLink
            @secret=''
            @mode="create"
            @type="add"
            @queryParams={{query-params initialKey=(or filter baseKey.id) itemType=tab}}
            @data-test-secret-create=true
          >
            {{options.create}}
          </ToolbarSecretLink>
        {{/unless}}
      </ToolbarActions>
    </Toolbar>
  {{/if}}

  {{#if model.meta.total}}
    {{#each model as |item|}}
      {{partial options.listItemPartial}}
    {{else}}
      <div class="box is-sideless">
        {{#if filterFocused}}
          There are no {{pluralize options.item}} matching <code>{{filter}}</code>, press <kbd>ENTER</kbd> to add one.
        {{else}}
          There are no {{pluralize options.item}} matching <code>{{filter}}</code>.
        {{/if}}
      </div>
    {{/each}}
    {{#if (gt model.meta.lastPage 1) }}
      {{list-pagination
        page=model.meta.currentPage
        lastPage=model.meta.lastPage
        link=(concat "vault.cluster.secrets.backend.list" (if (not baseKey.id) "-root"))
        model=(compact (array backend (if baseKey.id baseKey.id)))
      }}
    {{/if}}
  {{else}}
    {{#if (eq baseKey.id '')}}
      <EmptyState
        @title="No {{pluralize options.item}} in this backend yet"
        @message="Secrets in this backend will be listed here. Add a secret to get started."
      >
        {{#secret-link
          mode="create"
          secret=''
          queryParams=(query-params initialKey=(or filter baseKey.id) itemType=tab)
          class="link"
        }}
          {{options.create}}
        {{/secret-link}}
      </EmptyState>
    {{else}}
      {{#if filterIsFolder}}
        <EmptyState
          @title={{if (eq filter baseKey.id)
            (concat
              "No " (pluralize options.item) " under &quot;" this.filter "&quot;"
            )
            (concat
              "No folders matching &quot;" this.filter "&quot;"
            )
          }}
        />
      {{/if}}
    {{/if}}
  {{/if}}
{{/with}}
